package com.bie.action;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.woke.bean.ChouJBean;
import com.woke.bean.CustomerBean;
import com.woke.bean.UserBean;
import com.woke.dao.Customer;
import com.woke.dao.User;

public class ChouJAction implements Action, ServletRequestAware, ServletResponseAware, ServletContextAware {
	private HttpServletRequest request;
	private HttpServletResponse responese;
	private HttpSession session;
	private ServletContext application;
	private String cjname;
	private String id;
	private String msg;

	

	public String getCjname() {
		return cjname;
	}

	public void setCjname(String cjname) {
		this.cjname = cjname;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}

	public String execute() throws Exception {

		return null;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;

	}

	public void setServletResponse(HttpServletResponse response) {
		this.responese = response;

	}

	public void setServletContext(ServletContext application) {
		this.application = application;

	}
	
	public String updateChou() throws Exception {
		ChouJBean bm = new ChouJBean();
		cjname= new String(cjname.getBytes("ISO-8859-1"),"utf-8");
		bm.updateChouJ(id, cjname);
		return "Eventlist";
	}
	
	public String addChou() throws Exception {
		ChouJBean bm = new ChouJBean();
		cjname= new String(cjname.getBytes("ISO-8859-1"),"utf-8");
		bm.addChouJ(cjname);
		return "Eventlist";
	}
	
	public String deleChou() throws Exception {
		ChouJBean bm = new ChouJBean();
		bm.deleteChouJ(id);
		return "Eventlist";
	}
	
	public String getCustomerNum() throws Exception {
		Calendar now = Calendar.getInstance();  
		CeShiTime ce=new CeShiTime();
        Date d = new Date();  
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
        String dateNowStr = sdf.format(d); 
        Date endday=ce.getEndDayOfYesterDay();
		String sql1="select * from customer where cuscreatetime>='"+endday+"' and cuscreatetime<'"+dateNowStr+"' and isdele=1";
		List<Customer> list=Customer.getData(sql1);
		ActionContext actionContext = ActionContext.getContext();
		Map session = actionContext.getSession(); 
		System.out.println("sql1 :"+sql1);
		ActionContext.getContext().put("Customerlist", list);
		return "ChouJ";
	}

	
	
}
